{{- $count := default .Site.Params.featuredPostCount .Params.featuredPostCount }}
{{- $collapsed := default false .Site.Params.sidebar.collapsed }}
{{- if and $count (default false .Site.Params.sidebar.featuredPosts) }}
  {{- $featuredPosts := first $count (where (where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.featured" "eq" true) }}
  {{- with $featuredPosts }}
    <div class="accordion featured-posts">
      <section class="row card component">
        <div class="card-header">
          <h2 class="card-title my-2 fs-4 text-surface d-none d-lg-block">
            {{ i18n "featured_posts" }}
          </h2>
          <a
            class="accordion-button d-lg-none mb-1 shadow-none p-0 bg-transparent{{ cond $collapsed ` collapsed` `` }}"
            role="button"
            data-bs-toggle="collapse"
            href="#featured-posts"
            aria-expanded="{{ cond $collapsed `false` `true` }}"
            aria-controls="featured-posts">
            {{ i18n "featured_posts" }}
          </a>
        </div>
        <div
          class="card-body collapse accordion-collapse accordion-body d-lg-block{{ cond (not $collapsed) ` show` `` }}"
          id="featured-posts">
          <ul class="post-list list-unstyled ms-1">
            {{- range . }}
              <li class="mb-2">
                <a href="{{ .RelPermalink }}">
                  {{ partial "helpers/title" . }}
                </a>
              </li>
            {{- end }}
          </ul>
        </div>
      </section>
    </div>
  {{- end }}
{{- end }}
